<?php
/**
 * Uri Filter
 * Filters out non-URI values from input
 *
 * @package     Visi
 * @subpackage  Filters
 * @author      Luke Visinoni <luke.visinoni@gmail.com>
 * @copyright   (c) 2010 Luke Visinoni <luke.visinoni@gmail.com>
 * @version     $Id$
 */
class Visi_Filter_Uri extends Q_Filter_Abstract {

    /**
     * If the value that was passed in is a URI, make sure there is a trailing
     * slash. In the future I might add schemes and stuff.
     */
    public function doFilter($value) {
    
        if ($this->_isUri($value)) {
            return rtrim($value, '/') . '/';
        }
        return $value;
    
    }
    
    protected function _isUri($value) {
    
        $rule = new Q_Rule_Uri(array('scheme' => 'http', 'path' => false));
        return $rule->validate($value);
        
    
    }

}